package com.ruoyi.project.meal.utils;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.meal.domain.MealServiceObjects;
import com.ruoyi.project.meal.domain.MealServiceObjectsList;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据处理公共类
 */
public class DataParse {

    public static List<MealServiceObjects> parseObjects(List<MealServiceObjectsList> objectsLists){
        List<MealServiceObjects> list=new ArrayList<>();
        if(objectsLists==null || objectsLists.size()==0){
            return new ArrayList<>();
        }
        String reportingPerson="";
        for (MealServiceObjectsList m:objectsLists  ) {
            if(!StringUtils.isEmpty(m.getReportingPerson())){
                reportingPerson=m.getReportingPerson();
            }
        }
        MealServiceObjectsList sevice=objectsLists.get(0);
        MealServiceObjects zhushi=new MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"主食");
        MealServiceObjects liushi=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"流食");
        MealServiceObjects zhujidan=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"煮鸡蛋");
        MealServiceObjects zhenshuidan=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"蒸水蛋");
        MealServiceObjects yunjianshan=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"匀浆膳");
        MealServiceObjects niunai=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"牛奶");
        MealServiceObjects dianxin=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"点心");
        MealServiceObjects shuiguo=new  MealServiceObjects(sevice.getClassName(),sevice.getCampus(),reportingPerson,sevice.getReportDate(),"水果");
        for (MealServiceObjectsList m:objectsLists  ) {
            if("早餐".equals(m.getEat()) ){
                if("孤儿".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setmOrphan(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setmOrphan(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setmOrphan(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setmOrphan(m.getNumber());
                    }
                }else if("政府供养".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setmGove(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setmGove(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setmGove(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setmGove(m.getNumber());
                    }
                }else if("特困".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setmPoor(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setmPoor(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setmPoor(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setmPoor(m.getNumber());
                    }
                }else if("自费".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setmExpense(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setmExpense(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setmExpense(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setmExpense(m.getNumber());
                    }
                }else if("事无".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setmNothing(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setmNothing(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setmNothing(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setmNothing(m.getNumber());
                    }
                }
            } else if("晚餐".equals(m.getEat()) ){
                if("孤儿".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setdOrphan(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setdOrphan(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setdOrphan(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setdOrphan(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setdOrphan(m.getNumber());
                    }
                }else if("政府供养".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setdGove(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setdGove(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setdGove(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setdGove(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setdGove(m.getNumber());
                    }
                }else if("特困".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setdPoor(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setdPoor(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setdPoor(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setdPoor(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setdPoor(m.getNumber());
                    }
                }else if("自费".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setdExpense(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setdExpense(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setdExpense(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setdExpense(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setdExpense(m.getNumber());
                    }
                }else if("事无".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setdNothing(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setdNothing(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setdNothing(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setdNothing(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setdNothing(m.getNumber());
                    }
                }
            }else if("午餐".equals(m.getEat()) ){
                if("孤儿".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setlOrphan(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setlOrphan(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setlOrphan(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlOrphan(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlOrphan(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setlOrphan(m.getNumber());
                    }else if("牛奶".equals(m.getFood())){
                        niunai.setlOrphan(m.getNumber());
                    }else if("点心".equals(m.getFood())){
                        dianxin.setlOrphan(m.getNumber());
                    }else if("水果".equals(m.getFood())){
                        shuiguo.setlOrphan(m.getNumber());
                    }
                }else if("政府供养".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setlGove(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setlGove(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setlGove(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlGove(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setlGove(m.getNumber());
                    }else if("牛奶".equals(m.getFood())){
                        niunai.setlGove(m.getNumber());
                    }else if("点心".equals(m.getFood())){
                        dianxin.setlGove(m.getNumber());
                    } else if("水果".equals(m.getFood())){
                        shuiguo.setlGove(m.getNumber());
                    }
                }else if("特困".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setlPoor(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setlPoor(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setlPoor(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlPoor(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setlPoor(m.getNumber());
                    }else if("牛奶".equals(m.getFood())){
                        niunai.setlPoor(m.getNumber());
                    }else if("点心".equals(m.getFood())){
                        dianxin.setlPoor(m.getNumber());
                    }else if("水果".equals(m.getFood())){
                        shuiguo.setlPoor(m.getNumber());
                    }
                }else if("自费".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setlExpense(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setlExpense(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setlExpense(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlExpense(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setlExpense(m.getNumber());
                    }else if("牛奶".equals(m.getFood())){
                        niunai.setlExpense(m.getNumber());
                    }else if("点心".equals(m.getFood())){
                        dianxin.setlExpense(m.getNumber());
                    }else if("水果".equals(m.getFood())){
                        shuiguo.setlExpense(m.getNumber());
                    }
                }else if("事无".equals(m.getPerson())){
                    if("普食".equals(m.getFood())){
                        zhushi.setlNothing(Math.toIntExact(m.getNumber()));
                    }else if("流食".equals(m.getFood())){
                        liushi.setlNothing(m.getNumber());
                    }else if("煮鸡蛋".equals(m.getFood())){
                        zhujidan.setlNothing(m.getNumber());
                    }else if("蒸水蛋".equals(m.getFood())){
                        zhenshuidan.setlNothing(m.getNumber());
                    }else if("匀浆膳".equals(m.getFood())){
                        yunjianshan.setlNothing(m.getNumber());
                    }else if("牛奶".equals(m.getFood())){
                        niunai.setlNothing(m.getNumber());
                    }else if("点心".equals(m.getFood())){
                        dianxin.setlNothing(m.getNumber());
                    }else if("水果".equals(m.getFood())){
                        shuiguo.setlNothing(m.getNumber());
                    }
                }
            }
        }
        list.add(zhushi);
        list.add(liushi);
        list.add(zhujidan);
        list.add(zhenshuidan);
        list.add(yunjianshan);
        list.add(niunai);
        list.add(dianxin);
        list.add(shuiguo);
        return list;
    }

}
